package com.peanut.web.controller.yeebao;

import javax.servlet.http.HttpServletRequest;

import com.peanut.service.pay.data.PayEnum.PayCallbackMethod;
import com.peanut.service.pay.data.PayEnum.PayChannel;
import com.peanut.service.pay.data.yeebao.YeeBaoClientCallBackParam;
import com.peanut.service.pay.data.yeebao.YeeBaoServerCallBackParam;
import com.peanut.web.controller.BaseController;

/**
 * 易宝支付基础controller,处理一切与第三方对接的入口,注册,提现,充值,投资,余额查询,还款,债券转让,绑卡
 * 
 * @author jzsong@uworks.cc
 */
public class YeeBaoBaseController extends BaseController {

  /**
   * 成功标志
   */
  protected String SUCCESS = "SUCCESS";
  /**
   * 易宝label
   */
  protected String LABEL = PayChannel.YEEBAO.label;
  /**
   * 客户端回调界面
   */
  protected String CLIENT_PAGE = "page/clientCallBack.jsp";

  /**
   * 构建客户端返回参数
   * 
   * @param request
   * @return
   */
  protected YeeBaoClientCallBackParam buildClientCallBackParam(HttpServletRequest request) {
    String resp = request.getParameter("resp");
    String sign = request.getParameter("sign");
    YeeBaoClientCallBackParam param = new YeeBaoClientCallBackParam(resp, sign);
    param.setPayChannel(PayChannel.YEEBAO);
    param.setPayCallbackMethod(PayCallbackMethod.CLIENT);
    return param;
  }

  /**
   * 构建服务器端返回参数
   * 
   * @param request
   * @return
   */
  protected YeeBaoServerCallBackParam buildServerCallBackParam(HttpServletRequest request) {
    String notify = request.getParameter("notify");
    String sign = request.getParameter("sign");
    YeeBaoServerCallBackParam param = new YeeBaoServerCallBackParam(notify, sign);
    param.setPayChannel(PayChannel.YEEBAO);
    param.setPayCallbackMethod(PayCallbackMethod.SERVER);
    return param;
  }

}
